﻿<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="security"
	uri="http://www.springframework.org/security/tags"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@page import="java.io.FileOutputStream"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.io.File"%>
<%@page import="java.io.OutputStream"%>
<html>
<head>
<title>Muzycy.pl - serwis informacyjno usługowy o muzykach</title>
<META HTTP-EQUIV="Content-Type"
	CONTENT="text/html; charset=windows-1250">
<link href="css/styles.css" rel="stylesheet" type="text/css">
</head>

<div id="body">
	<div id="menu">
		<div class="logged">
		Zalogowany jako: <b><security:authentication
						property="principal.username" /></b>
		</div>
		<ul>
			<li>
			<a href="mojekonto.htm" class="active"><img src="images/butt_myaccount.jpg" alt="" width="140" height="67" />	</a>
			</li>
			<li>
			<a href="listnews.htm"><img src="images/butt_news.jpg"	alt="" width="100" height="67" /></a>
			</li>
			<li>
			<a href="szukaj.htm"><img src="images/butt_szukajt.jpg" alt="" width="100" height="67" /></a>
			</li>
			<li>
			<a href="logout.htm"><img src="images/butt_logout.jpg" alt="" width="125" height="67" /></a>
			</li>			
		</ul>
		
		<div class="slogan">
			<img src="images/slogan_moje_konto.jpg" alt="" width="594" height="144" />
		</div>
	</div>
	<div id="overview">
		
		<div id="box">
			<ul id="tabs">
				<li><a href="#box_1">Dane użytkownika </a></li>
				<li><a href="#box_2">Moje newsy</a></li>
				<li><a href="#box_3">Dodaj newsa</a></li>
				
			</ul>
			<ul id="boxes">

				
					<li id="box_2" class="box" style=" overflow: scroll;">
					<c:if test="${fn:length(userNews) > 0}">
						
							<h1>Moje newsy:</h1>
							<c:forEach items="${userNews}" var="news" varStatus="status">
								<br/><h2><c:out value="Tytuł: ${news.title }" /></h2>
								<h4><a href="news.htm?id=${news.id }"><c:out value="Przejdź do strony newsa..." /></a> </h4>
									 
								<h4>Data ostatniej modyfikacji:	${news.last_update}</h4>
								
								<br/>
									${news.news}
								<br/>
								<br/><b>Tagi: </b>
								<c:forEach items="${news.tags }" var="tag">
									<c:out value="${tag.name }"></c:out>;&nbsp;
								</c:forEach>
								<br/><br/>
								
								<form:form action="editnews.htm?news_id=${news.id}" commandName="news">
								<input type="submit" value="Edytuj" class="myButton"/>
								</form:form>
								<form:form action="deletenews.htm?news_id=${news.id}" commandName="news">
								<input type="submit" value="Usuń" class="myButton"/>
								</form:form>
								
								
							</c:forEach>
						
					</c:if>
					</li>
				<li id="box_3" class="box">
									
					<form:form action="addnews.htm" commandName="news">
							<h1>Dodawanie newsa:</h1>
							<br/>
							<ul>							
								<li>Tytuł :</li>
								<li><form:input path="title" /></li>
								<li><span style="color: red"><c:out value="${titleError}" /> </span></li>
							</ul>
							<ul>
								<li>Treść newsa :</li>
								<li><form:textarea rows="5" cols="50" path="news" /></li>
								<li><span style="color: red"><c:out
											value="${newsError}" /> </span></li>
							</ul>
							<ul> </ul><ul> </ul><ul> </ul><ul> </ul><ul> </ul><ul> </ul>
							<ul>
								<li>Tagi:</li>
								<li><form:select  id="tags" multiple="true" path="tags">
											<form:options items="${tagList }" itemValue="name"
												itemLabel="name" />
										</form:select>
								</li>
							</ul>	
							<ul>
								<li><input type="submit" class="myButton2"
									value="Dodaj">
								</li>
							</ul>
					</form:form>
				</li>
				
				
				<li id="box_1" class="box">
					<h1>Dane użytkownika: </h1> <br />
					<form:form action="changeuserdata.htm" commandName="user">
						<ul>
							<li>Imię:</li>
							<li><input type="text" name="name" value="${user.name}"/> </li>
							<li><span class="warning"><c:out value="${nameError}"/></span></li>
						</ul>
						<ul>
							<li>Nazwisko:</li>
							<li><input type="text" name="lastname" value="${user.lastname}"/> </li>
							<li><span class="warning"><c:out value="${lastnameError}"/></span></li>
						</ul>
						<ul>
							<li>Email:</li>
							<li><input type="text" name="email" value="${user.email}"/> </li>
							<li><span class="warning"><c:out value="${emailError}"/></span></li>
						</ul>
						<ul>
							<li>Telefon:</li>
							<li><input type="text" name="telephone" value="${user.telephone}"/> </li>
							<li><span class="warning"><c:out value="${telephoneError}"/></span></li>
						</ul>
						<ul>
							<li>Miasto:</li>
							<li><input type="text" name="city" value="${user.city}"/> </li>
							<li><span class="warning"><c:out value="${cityError}"/></span></li>
						</ul>
						<ul>
							<li>Państwo:</li>
							<li><input type="text" name="country" value="${user.country}"/> </li>
							<li><span class="warning"><c:out value="${countryError}"/></span></li>
						</ul>
						<%-- <ul>
							<li>Dołączył:</li>
							<li><c:out value="${user.joined}"></c:out></li>
						</ul> --%>
						<ul>
							<li/><li><input type="submit" class="myButton2" value="Zmień dane"></li>
						</ul>
					</form:form>
					</li>
			</ul>

		</div>

		<div id="footer" style="margin-left:0px">
			<div id="copyright">
				Copyright Czesiu. All rights reserved. Design by <a
					href="http://nyan.cat">NyanCat</a>
			</div>
		</div>
	</div>
</div>
</html>